package com.ics.web.controller.travelstar.controller;

import com.ics.common.annotation.Log;
import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.AjaxResult;
import com.ics.common.enums.BusinessType;
import com.ics.web.controller.travelstar.domain.TiresRegister;
import com.ics.web.controller.travelstar.dto.TiresRegisterDTO;
import com.ics.web.controller.travelstar.service.ITbTiresRegisterService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * 留言信息Controller
 *
 * @author ics
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/tires/register")
public class TbTiresRegisterController extends BaseController {
    @Resource
    private ITbTiresRegisterService tbTiresRegisterService;

    /**
     * 查询留言信息列表
     */
    @ApiOperation("查询留言信息列表")
    @GetMapping("/list")
    public AjaxResult list(TiresRegisterDTO registerDTO) {
        return success(tbTiresRegisterService.listPage(registerDTO));
    }


    /**
     * 获取留言信息详细信息
     */
    @ApiOperation("获取留言信息详细信息")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tbTiresRegisterService.getById(id));
    }

    /**
     * 新增留言信息
     */
    @ApiOperation("新增留言信息")
    @Log(title = "留言信息", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody TiresRegister tbTiresRegister) {
        return toAjax(tbTiresRegisterService.saveOrUpdate(tbTiresRegister));
    }


    /**
     * 删除留言信息
     */
    @ApiOperation("删除留言信息")
    @Log(title = "留言信息", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(tbTiresRegisterService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
